﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using System.Collections;

using Engine;
using Gencode;
using Library;

namespace GameTool
{
    public partial class MainForm : Form
    {
        public LoginForm loginForm;
        public SapXep_Form1 SapXepForm1;
        public SoSanh_Form1 SoSanhForm1;
        public TreoKhi_Form1 TreoKhiForm1;
        public DuaXe_Form1 DuaXeForm1;
        public MeCung_Form1 MeCungForm1;
        public DangThuc_Form1 DangThucForm1;
        public PhepTinh_Form1 PhepTinhForm1;
        public CocVang_Form1 CocVangForm1;
        public CocVang_Form2 CocVangForm2;
        public MainForm()
        {
            InitializeComponent();
            ftp_main.open();
            Init();            
        }

        private void Init()
        {
            loginForm = new LoginForm();
            loginForm.mainForm = this;
        }

        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
        }

        private void cmdSX_Click(object sender, EventArgs e)
        {
            this.Hide();
            SapXepForm1 = new SapXep_Form1();
            SapXepForm1.mainForm = this; 
            this.SapXepForm1.ShowDialog();
            this.Show();
        }

        private void cmdSS_Click(object sender, EventArgs e)
        {
            this.Hide();
            SoSanhForm1 = new SoSanh_Form1();
            SoSanhForm1.mainForm = this;
            this.SoSanhForm1.ShowDialog();
            this.Show();
        }

        private void cmdTK_Click(object sender, EventArgs e)
        {
            this.Hide();
            TreoKhiForm1 = new TreoKhi_Form1();
            TreoKhiForm1.mainForm = this;
            this.TreoKhiForm1.ShowDialog();
            this.Show();
        }

        private void cmdDX_Click(object sender, EventArgs e)
        {
            this.Hide();
            DuaXeForm1 = new DuaXe_Form1();
            DuaXeForm1.mainForm = this;
            this.DuaXeForm1.ShowDialog();
            this.Show();
        }

        private void cmdMC_Click(object sender, EventArgs e)
        {
            this.Hide();
            MeCungForm1 = new MeCung_Form1();
            MeCungForm1.mainForm = this;
            this.MeCungForm1.ShowDialog();
            this.Show();
        }

        private void cmdDT_Click(object sender, EventArgs e)
        {
            this.Hide();
            DangThucForm1 = new DangThuc_Form1();
            DangThucForm1.mainForm = this;
            this.DangThucForm1.ShowDialog();
            this.Show();
        }

        private void cmdPT_Click(object sender, EventArgs e)
        {
            this.Hide();
            PhepTinhForm1 = new PhepTinh_Form1();
            PhepTinhForm1.mainForm = this;
            this.PhepTinhForm1.ShowDialog();
            this.Show();
        } 

        private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

        private void cmdRelax_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process[] tmp = System.Diagnostics.Process.GetProcessesByName("XepHinh");

            if (tmp.Length == 0)
                System.Diagnostics.Process.Start("XepHinh.exe");
            else
            {
                MessageBox.Show("Chương trình đang chạy!", "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            if(User.UserName == "administrator")
            {
                this.Size = new Size(445, 452);
                this.cmdAdmin.Visible = true;
            }
            else
            {
                this.Size = new Size(445, 375);
                this.cmdAdmin.Visible = false;
            }
        }

        private void cmdAdmin_Click(object sender, EventArgs e)
        {
            Permission permission = new Permission();
            permission.ShowDialog();
        }

        private void BT_CocVangBanBong_Click(object sender, EventArgs e)
        {
            this.Hide();
            CocVangForm1 = new CocVang_Form1();
            CocVangForm1.mainForm = this;
            this.CocVangForm1.ShowDialog();
            this.Show();
        }             
    }
}
